package com.example.admin.goodnews.adapter;

import android.content.Context;
import android.support.v7.widget.RecyclerView;
import android.support.v7.widget.RecyclerView.Adapter;
import android.view.LayoutInflater;
import android.view.MotionEvent;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import com.example.admin.goodnews.R;
import com.example.admin.goodnews.entity.DailyRankDataEntity;
import com.example.admin.goodnews.interfaces.RecyclerViewItemClickListener;
import com.example.admin.goodnews.interfaces.RecyclerViewItemLongClickListener;

/**
 * Created by admin on 2016/10/13.
 */

public class DailyRankAdapter extends RecyclerView.Adapter<DailyRankAdapter.ViewHolder> {
    private Context context;
    private DailyRankDataEntity dailyRankDataEntity;

    public DailyRankAdapter(Context context, DailyRankDataEntity dailyRankDataEntity) {
        this.context = context;
        this.dailyRankDataEntity = dailyRankDataEntity;
    }

    @Override
    public ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
        View view = LayoutInflater.from(context).inflate(R.layout.item_dailyrank, null);
        ViewHolder holder = new ViewHolder(view);
        return holder;
    }

    @Override
    public void onBindViewHolder(final ViewHolder holder, int position) {
        holder.tv_moviename_dailyrank.setText("电影院名：" + dailyRankDataEntity.getShowapi_res_body().getDatalist().get(position).getMovieName());
        holder.tv_todaybox_dailyrank.setText("票房统计：" + dailyRankDataEntity.getShowapi_res_body().getDatalist().get(position).getTodayBox());
        holder.tv_todayshowcount_dailyrank.setText("今日上映场数：" + dailyRankDataEntity.getShowapi_res_body().getDatalist().get(position).getTodayShowCount());
        holder.tv_avgpeople_dailyrank.setText("场均人次：" + dailyRankDataEntity.getShowapi_res_body().getDatalist().get(position).getAvgPeople());
        holder.tv_attendance_dailyrank.setText("上座率：" + dailyRankDataEntity.getShowapi_res_body().getDatalist().get(position).getAttendance());
        holder.v_rownum_dailyrank.setText("单座排名：" + dailyRankDataEntity.getShowapi_res_body().getDatalist().get(position).getRowNum());
    }

    @Override
    public int getItemCount() {
        return dailyRankDataEntity.getShowapi_res_body().getDatalist().size();
    }

    public class ViewHolder extends RecyclerView.ViewHolder {
        private TextView tv_moviename_dailyrank;// 电影院名
        private TextView tv_todaybox_dailyrank;// 票房统计
        private TextView tv_todayshowcount_dailyrank;// 今日上映场数
        private TextView tv_avgpeople_dailyrank;// 场均人次
        private TextView tv_attendance_dailyrank;// 上座率
        private TextView v_rownum_dailyrank;// 单座排名

        public ViewHolder(View itemView) {
            super(itemView);
            tv_moviename_dailyrank = (TextView) itemView.findViewById(R.id.tv_moviename_dailyrank);// 电影院名
            tv_todaybox_dailyrank = (TextView) itemView.findViewById(R.id.tv_todaybox_dailyrank);// 票房统计
            tv_todayshowcount_dailyrank = (TextView) itemView.findViewById(R.id.tv_todayshowcount_dailyrank);// 今日上映场数
            tv_avgpeople_dailyrank = (TextView) itemView.findViewById(R.id.tv_avgpeople_dailyrank);// 场均人次
            tv_attendance_dailyrank = (TextView) itemView.findViewById(R.id.tv_attendance_dailyrank);// 上座率
            v_rownum_dailyrank = (TextView) itemView.findViewById(R.id.v_rownum_dailyrank);// 单座排名
        }
    }

}
